home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / option.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-05  |  3.1 KB  |  161 lines

  1. // $Id: option.h,v 1.8 1999/07/06 13:49:24 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10.  
  11. #ifndef option_INCLUDED
  12. #define option_INCLUDED
  13.  
  14. #include "config.h"
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include "code.h"
  19. #include "tuple.h"
  20. #ifdef AMIGAOS_FILE_SYSTEM
  21. #include <unistd.h>
  22. #include <sys/param.h>
  23. #endif
  24.  
  25. class ArgumentExpander
  26. {
  27. public:
  28.  
  29.     int argc;
  30.     char **argv;
  31.  
  32.     ArgumentExpander::ArgumentExpander(int, char **);
  33.  
  34.     ArgumentExpander(Tuple<char> &);
  35.  
  36.     ~ArgumentExpander()
  37.     {
  38.         for (int i = 0; i < argc; i++)
  39.             delete [] argv[i];
  40.         delete [] argv;
  41.     }
  42.  
  43.     bool ArgumentExpanded(Tuple<char *> &, char *);
  44. };
  45.  
  46.  
  47. class KeywordMap
  48. {
  49. public:
  50.     wchar_t *name;
  51.     int length,
  52.         key;
  53. };
  54.  
  55.  
  56. class OptionError
  57. {
  58. public:
  59.     int kind;
  60.     wchar_t *name;
  61.  
  62.     OptionError(int kind_, char *str) : kind(kind_)
  63.     {
  64.         int length = strlen(str);
  65.         name = new wchar_t[length + 1];
  66.         for (int i = 0; i < length; i++)
  67.             name[i] = str[i];
  68.         name[length] = U_NULL;
  69.  
  70.         return;
  71.     }
  72.  
  73.     ~OptionError() { delete [] name; }
  74. };
  75.  
  76.  
  77. class Ostream;
  78.  
  79. class Option
  80. {
  81. #ifdef WIN32_FILE_SYSTEM
  82.     char main_disk,
  83.          *current_directory[128];
  84.  
  85. public:
  86.     bool BadMainDisk() { return main_disk == 0; }
  87.  
  88.     bool IsMainDisk(char c) { return c != 0 && current_directory[c] == current_directory[main_disk]; }
  89.  
  90.     void SaveCurrentDirectoryOnDisk(char);
  91.  
  92.     void ResetCurrentDirectoryOnDisk(char d)
  93.     {
  94.         if (d != 0)
  95.         {
  96.             assert(current_directory[d]);
  97.  
  98.             SetCurrentDirectory(current_directory[d]);
  99.         }
  100.     }
  101.     void SetMainCurrentDirectory()
  102.     {
  103.         SetCurrentDirectory(current_directory[main_disk]);
  104.     }
  105.     char *GetMainCurrentDirectory()
  106.     {
  107.         return current_directory[main_disk];
  108.     }
  109. #elif defined(AMIGAOS_FILE_SYSTEM)
  110. public:
  111.     char *GetMainCurrentDirectory()
  112.     {
  113.     static char buf[MAXPATHLEN+1];
  114.     return getcwd(buf, sizeof(buf));
  115.     }
  116. #endif
  117.  
  118. public:
  119.     char *default_path,
  120.          *classpath,
  121.          *directory,
  122.          *makefile_name;
  123.  
  124.     Tuple<KeywordMap> keyword_map;
  125.     Tuple<OptionError *> bad_options;
  126.  
  127.     bool nowrite,
  128.          deprecation,
  129.          O,
  130.          g,
  131.          verbose,
  132.          depend,
  133.          nowarn,
  134.          one_one,
  135.          zero_defect;
  136.     int first_file_index;
  137.  
  138.     int debug_trap_op;
  139.  
  140.     bool debug_dump_lex,
  141.          debug_dump_ast,
  142.          debug_dump_class,
  143.          applet_author,
  144.          incremental,
  145.          makefile,
  146.          bytecode,
  147.          full_check,
  148.          unzip,
  149.          dump_errors,
  150.          errors,
  151.          ascii, // used on EBCDIC systems to AVOID input translation from EBCDIC to ASCII
  152.          comments,
  153.          pedantic;
  154.  
  155.     Option(ArgumentExpander &);
  156.  
  157.     ~Option();
  158. };
  159.  
  160. #endif /* option_INCLUDED */
  161.